<template>
  <div id="swiper">
    <div id="slideshow">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item, index) in swiper" :key="index">
            <router-link to=''>
              <img :src="item.img" alt="" srcset="">
            </router-link>
          </div>
        </div>
        <!-- 分页器 -->
        <div class="swiper-pagination"></div>
      </div>
    </div>
  </div>
</template>

<script>
import Swiper from 'swiper'
export default {
  name: 'swiper',
  props: ['swiper'],
  mounted () {
    // eslint-disable-next-line no-unused-vars
    var mySwiper = new Swiper('.swiper-container', {
      autoplay: {
        delay: 2000, // 切换事间
        disableOnInteraction: false // false触碰后自动切换不会停止/ture相反
      },
      direction: 'horizontal', // 垂直切换选项
      loop: true, // 循环模式选项

      // 分页器
      pagination: {
        el: '.swiper-pagination'
      }
    })
  }
}
</script>

<style scoped lang="less">
#swiper {
  text-align: center;
  img {
    border-radius: 15px;
  }
}
</style>
